package com.bigdata.service.mysql.impl;

import com.bigdata.model.Result;
import com.bigdata.model.SearchModel;
import com.bigdata.mysql.dao.JkfwRoleMenuMapper;
import com.bigdata.mysql.entity.JkfwRoleMenu;
import com.bigdata.mysql.entity.JkfwRoleMenuExample;
import com.bigdata.service.mysql.JkfwRoleMenuService;
import com.bigdata.service.mysql.base.impl.BaseService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * JkfwRoleMenu的服务接口的实现类
 *
 * @author
 */
@Service
public class JkfwRoleMenuServiceImpl extends BaseService<JkfwRoleMenuMapper, JkfwRoleMenu, JkfwRoleMenuExample> implements JkfwRoleMenuService {
    private final Logger LOG = LogManager.getLogger(this.getClass());


    @Override
    public Result queryPage(SearchModel searchModel) {
        return null;
    }

    @Override
    public List<String> queryMenuRole(String roleid) {
        JkfwRoleMenuExample example = new JkfwRoleMenuExample();
        example.createCriteria().andRoleIdEqualTo(roleid);
        List<JkfwRoleMenu> list = dao.selectByExample(example);
        List<String> menus = new ArrayList<String>();
        for (JkfwRoleMenu roleMenu : list) {
            menus.add(roleMenu.getMenuId());
        }
        return menus;
    }

    @Override
    public void delMenuid(String menuid) {
        JkfwRoleMenuExample example = new JkfwRoleMenuExample();
        example.createCriteria().andMenuIdEqualTo(menuid);
        dao.deleteByExample(example);
    }

    @Override
    public void delRoleid(String roleid) {
        JkfwRoleMenuExample example = new JkfwRoleMenuExample();
        example.createCriteria().andRoleIdEqualTo(roleid);
        dao.deleteByExample(example);
    }
}